
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mytools;

import com.opensymphony.xwork2.ActionSupport;

/**

 *

 * @author xiaoxiao

 */
public class upageAction extends ActionSupport {

    private int pagenumber;
    private int totalpage;
    private int pagesize;

    public upageAction() {
    }

    public String execute() throws Exception {

        userDAO ud = new userDAO();
        pagesize = 6;
        int questionAmount = ud.getuserAmount();
        this.totalpage = questionAmount % pagesize == 0 ? (questionAmount / pagesize) : (questionAmount / pagesize + 1);
        if (this.pagenumber <= 0) {
            this.pagenumber = 1;
        }
        if (this.pagenumber > totalpage) {
            this.pagenumber = totalpage;
        }
        return SUCCESS;
    }

    /**
     * @return the pagenumber
     */
    public int getPagenumber() {
        return pagenumber;
    }

    /**
     * @param pagenumber the pagenumber to set
     */
    public void setPagenumber(int pagenumber) {
        this.pagenumber = pagenumber;
    }

    /**
     * @return the totalpage
     */
    public int getTotalpage() {
        return totalpage;
    }

    /**
     * @param totalpage the totalpage to set
     */
    public void setTotalpage(int totalpage) {
        this.totalpage = totalpage;
    }

    /**
     * @return the pagesize
     */
    public int getPagesize() {
        return pagesize;
    }

    /**
     * @param pagesize the pagesize to set
     */
    public void setPagesize(int pagesize) {
        this.pagesize = pagesize;
    }
}
